<template>
  <div>
    <h1>抽取分类维护页面</h1>
    <el-tree :data="data" @node-click="nodeClick" :props="defaultProps">
    </el-tree>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  data() {
    return {
      data: [],
      defaultProps: {
        children: "children",
        label: "name", // 要修改成name
      },
    };
  },
  methods: {
    //事件的发布
    nodeClick(node) {
      if (node.catLevel == 3) {
        PubSub.publish("node", node);
      }
    },
    //列表的展示
    getTreeList() {
      this.$http({
        url: this.$http.adornUrl(`/produce/category/tree/list`),
        method: "get",
        params: this.$http.adornParams(),
      }).then(({ data }) => {
        console.log(data);
        this.data = data.list;
      });
    },
  },

  created() {
    this.getTreeList();
  },
};
</script>


